<?php
if (!defined('BASEPATH'))
	exit('No direct script access allowed');

include 'securities.php';

class Manage_feedback extends Securities {

	function __construct() {
		parent::__construct('manage_feedback');
		$this -> form_validation -> set_error_delimiters('<span class="error">', '</span>');
	}

	public function index() {
		$data['title'] = $this->lang->line('title_feedbacks');
		$data['controller_name'] = strtolower(get_class());
		$data['manage_datatable'] = get_feedback_manage_table($this -> mod_globals -> select_all(PREFIX_TABLE . 'feedback'), $this -> uri -> segment(1));
		$this -> load -> view(B_MASTER . 'index', $data);

	}

	public function delete_feedback() {
		$module_id = $this -> uri -> segment(1);
		if (!$this -> is_has_modify_permission($module_id)) {
			redirect('ctm-common/no-allow-modify/' . $module_id);
		}

		$feedback_id = $this -> uri -> segment(3);
		$is_deleted = $this -> mod_globals -> delete(PREFIX_TABLE . "feedback", array('feedback_id' => $feedback_id));
		if ($is_deleted) {
			$this -> session -> set_flashdata('success', 'Feedback  was deleted success.');
			redirect('manage-feedback');
		} else {
			$this -> session -> set_flashdata('error', 'Feedback  was deleted fail.');
			redirect('manage-feedback');
		}
	}

}
